<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>路由组件传参</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-view></router-view>
    </div>
    <script>
        const User={
            props:["id"],
            template:`
            <div>
                <p>路由组件传参:{{id}}</p> 
                <p>依赖router：{{$route.params.id}}</p>
            </div>          
            `};

        const routes = [
            {
                path:"/user/:id",
                component:User,
                
                props:true
            },
        
        ];

        const router = new VueRouter({
            routes,
        })

        const app = new Vue({
            el:"#app",
            router,
        })
    </script>
</body>
</html>